<?php
/**
 * Created by PhpStorm
 * User: honglin
 * Date: 2022/8/5
 * Time: 下午2:02
 */

namespace App\Controller\Admin\System;


use App\Controller\Admin\BaseController;

use App\Service\System\SystemConfigService;
use Hyperf\Di\Annotation\Inject;
use Yj\Apidog\Annotation\ApiController;
use Yj\Apidog\Annotation\FormData;
use Yj\Apidog\Annotation\PostApi;


/**
 * @ApiController(prefix="admin/system/config")
 */
class SystemConfigController extends BaseController
{

    /**
     * @Inject()
     * @var SystemConfigService
     */
    protected $systemConfigService;

    /**
     * @PostApi(path="lists")
     */
    public function lists(){
        $params = $this->getParams();
        $data = $this->systemConfigService->lists($params);
        _SUCCESS($data);
    }

    /**
     * @PostApi(path="add")
     * @FormData(key="classify_id")
     * @FormData(key="info")
     * @FormData(key="key")
     * @FormData(key="name")
     * @FormData(key="status")
     * @FormData(key="sort")
     */
    public function add(){
        $params = $this->getParams();
        $this->systemConfigService->add($params);
        _SUCCESS();
    }

    /**
     * @return void
     * @PostApi(path="edit")
     * @FormData(key="classify_id")
     * @FormData(key="config_id")
     * @FormData(key="info")
     * @FormData(key="key")
     * @FormData(key="name")
     * @FormData(key="status")
     * @FormData(key="sort")
     */
    public function edit(){
        $params = $this->getParams();
        $this->systemConfigService->edit($params->get('config_id'),$params->except('config_id'));
        _SUCCESS();
    }
}